home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Classes / Neural-Network / Neuron.h < prev    next >
Encoding:
Text File  |  1992-07-29  |  2.2 KB  |  65 lines

  1. /* =======================================================
  2.     Neural Network Classes for the NeXT Computer
  3.     Written by: Ralph Zazula
  4.                     University of Arizona - Fall 1991
  5.                     zazula@pri.com (NeXT Mail)
  6. ==========================================================*/
  7. /*$Log:    Neuron.h,v $
  8.  * Revision 1.2  92/01/14  21:20:28  zazula
  9.  * Check in before HashTable mod
  10.  * 
  11.  * Revision 1.1  92/01/02  12:42:30  zazula
  12.  * Initial revision
  13.  * */
  14. #import <objc/Object.h>
  15. #import <objc/List.h>
  16. #import <objc/Storage.h>
  17. #import "Random.h"                    // Random number generator
  18.  
  19. typedef     struct {
  20.     id                source;
  21.     double        weight;
  22.     struct connection    *next;
  23. } connection;
  24.  
  25. @interface Neuron:Object
  26.  
  27. #define Binary 0                        // Node Types
  28. #define Sigmoid 1
  29. #define Sign 2
  30. #define Tanh 3
  31.  
  32. {
  33.     id            inputs;            // list of Neuron's that are inputs to this Neuron
  34.     double    lastOutput;        // output value from last time step
  35.     double    T;                    // Temperature
  36.     
  37.     id            random;            // Random instance
  38.     int        nodeType;        // the type of this node
  39.     connection     *head,        // the head of the linked list
  40.                     *tail;        // the tail of the linked list
  41.     BOOL         Symmetric;        // symmetric connections?
  42.                     
  43. }
  44. - (double)activation:(double)net;
  45. - init;                            // initialization method
  46. - step;                            // read inputs and generate output 
  47. - inputs;                        // returns a pointer to the List of inputs    
  48. - (double)lastOutput;        // returns the last output value of the Neuron
  49. - connect:sender;                // add sender to the list of inputs to this Neuron
  50. - connect:sender withWeight:(double)weight;
  51. - (double)getWeightFor:source;            
  52.                                     // returns the weight for the given input Neuron
  53. - setWeightFor:source to:(double)weight;
  54.                                     // sets the weight for the given input Neuron
  55. - setOutput:(double)output;// set the output value manually (used for inputs)
  56. - changeWeightFor:source by:(double)delta;
  57. - setType:(int)type;            // set the type of node - determines the activation
  58.                                     // function
  59. - (int)getType;                // returns the node type for this Neuron
  60. - setTemp:(double)newT;        // set the temperature for the neuron
  61. - (double)getTemp;            // returns the temperature
  62. - setRandom:theRandom;        // set random number generator pointer
  63. - setSymmetric:(BOOL)sym;    // set symmetric connection status
  64. - (BOOL)getSymmetric;        // return the symmetric connection status
  65. @end